# —*— coding: utf-8 -*-

import logging
from functools import singledispatch

logger = logging.getLogger(__name__)


@singledispatch
def parameter(instance):
    """
    实现单分派泛函数：根据第一个参数类型来决定调用不同实现
    Parameters
    ----------
    instance

    Returns
    -------

    """
    logger.error(f'illegal parameter:{instance}')


@parameter.register(int)
def parameter1(instance):
    logger.error(f'type:int parameter:{instance}')
    pass


@parameter.register(str)
def parameter2(instance):
    logger.error(f'type:str parameter:{instance}')
    pass


if __name__ == '__main__':
    parameter(123)
    parameter(123.456)
    parameter('abc')

    pass
